package com.example.demo;

import com.example.demo.advice.EncryptRequestBodyAdvice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.web.reactive.accept.RequestedContentTypeResolver;


@SpringBootApplication
@EnableReactiveMongoRepositories
public class DemoApplication {

    @Autowired
    ServerCodecConfigurer serverCodecConfigurer;
    @Autowired
    RequestedContentTypeResolver requestedContentTypeResolver;

    @Autowired
    ReactiveAdapterRegistry reactiveAdapterRegistry;


    @Bean
    EncryptRequestBodyAdvice requestBodyAdvice() {
        return new EncryptRequestBodyAdvice(serverCodecConfigurer.getReaders(), reactiveAdapterRegistry);
    }

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}
